import { Map } from 'immutable'

import * as actionTypes from './constants'

const defaultState = Map({
  topBanners: [],
  hotRecommends: [],
  newAlbums: [],
  uplist: {},
  newlist: {},
  prevlist: {},
  artistList: []
})

function reducer(state = defaultState, action) {
  switch(action.type) {
    case actionTypes.CHANGE_TOP_BANNERS:
      return state.set("topBanners", action.topBanners)
    case actionTypes.CHANGE_HOT_RECOMMENDS:
      return state.set("hotRecommends", action.hotRecommends)
    case actionTypes.CHANGE_NEW_ALBUMS:
      return state.set("newAlbums", action.newAlbums)
    case actionTypes.CHANGE_UP_LIST:
      return state.set("uplist", action.uplist)
    case actionTypes.CHANGE_NEW_LIST:
      return state.set("newlist", action.newlist)
    case actionTypes.CHANGE_PREV_LIST:
      return state.set("prevlist", action.prevlist)
    case actionTypes.CHANGE_ARTIST_LIST:
      return state.set("artistList", action.artistList)
    default:
      return state
  }
}

export default reducer